home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / wordml2ooo_path.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  116KB  |  1,827 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: wordml2ooo_path.xsl,v $
  7.  
  8.     $Revision: 1.5 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:12:45 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="w wx aml o dt  v">
  37.     <xsl:include href="../../common/math.xsl"/>
  38.     <xsl:template name="dummy">
  39.         <xsl:call-template name="test"/>
  40.     </xsl:template>
  41.     <xsl:template name="test-arc">
  42.         <xsl:call-template name="svg-arc2vml-arc">
  43.             <!--  M 125,75 a100,50 0 ?,? 100,50 -->
  44.             <xsl:with-param name="x0" select="125"/>
  45.             <xsl:with-param name="y0" select="75"/>
  46.             <xsl:with-param name="rx" select="100"/>
  47.             <xsl:with-param name="ry" select="50"/>
  48.             <xsl:with-param name="x-axis-rotation" select="0"/>
  49.             <xsl:with-param name="large-arc-flag" select="0"/>
  50.             <xsl:with-param name="sweep-flag" select="0"/>
  51.             <xsl:with-param name="x" select="225"/>
  52.             <xsl:with-param name="y" select="125"/>
  53.         </xsl:call-template>
  54.     </xsl:template>
  55.     <xsl:template name="test">
  56.         <xsl:call-template name="vmlpath2svgpath">
  57.             <xsl:with-param name="vml-path" select="'m,l,4500,3420,2520,6120,4500r2160,l6660,3240,8460,2520,8460,,3960,540r360,720l2700,1260,3240,540,,xe'"/>
  58.         </xsl:call-template>
  59.     </xsl:template>
  60.     <xsl:template name="vmlpath2svgpath">
  61.         <xsl:param name="vml-path"/>
  62.         <xsl:param name="svg-path" select="''"/>
  63.         <xsl:param name="position" select="1"/>
  64.         <xsl:param name="last-command" select="'m'"/>
  65.         <xsl:param name="current-x" select="'0'"/>
  66.         <xsl:param name="current-y" select="'0'"/>
  67.         <xsl:variable name="command-and-newpos">
  68.             <xsl:call-template name="get-path-command">
  69.                 <xsl:with-param name="vml-path" select="$vml-path"/>
  70.                 <xsl:with-param name="position" select="$position"/>
  71.                 <xsl:with-param name="last-command" select="$last-command"/>
  72.             </xsl:call-template>
  73.         </xsl:variable>
  74.         <xsl:variable name="command" select="substring-before($command-and-newpos , ':')"/>
  75.         <xsl:variable name="newpos" select="substring-after($command-and-newpos , ':')"/>
  76.         <xsl:choose>
  77.             <xsl:when test="$command = 'm' ">
  78.                 <!-- absolute moveto -->
  79.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' M ' ) "/>
  80.                 <xsl:variable name="num-and-pos">
  81.                     <xsl:call-template name="get-number-after">
  82.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  83.                         <xsl:with-param name="position" select="$newpos"/>
  84.                         <xsl:with-param name="count" select="2"/>
  85.                     </xsl:call-template>
  86.                 </xsl:variable>
  87.                 <xsl:call-template name="vmlpath2svgpath">
  88.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  89.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  90.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  91.                     <xsl:with-param name="last-command" select="$command"/>
  92.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  93.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  94.                 </xsl:call-template>
  95.             </xsl:when>
  96.             <xsl:when test="$command = 't' ">
  97.                 <!-- relative moveto -->
  98.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' m ' ) "/>
  99.                 <xsl:variable name="num-and-pos">
  100.                     <xsl:call-template name="get-number-after">
  101.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  102.                         <xsl:with-param name="position" select="$newpos"/>
  103.                         <xsl:with-param name="count" select="2"/>
  104.                     </xsl:call-template>
  105.                 </xsl:variable>
  106.                 <xsl:call-template name="vmlpath2svgpath">
  107.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  108.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  109.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  110.                     <xsl:with-param name="last-command" select="$command"/>
  111.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')    , ' ')  + $current-x"/>
  112.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ') + $current-y "/>
  113.                 </xsl:call-template>
  114.             </xsl:when>
  115.             <xsl:when test="$command = 'l' ">
  116.                 <!-- absolute lineto -->
  117.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' L ' ) "/>
  118.                 <xsl:variable name="num-and-pos">
  119.                     <xsl:call-template name="get-number-after">
  120.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  121.                         <xsl:with-param name="position" select="$newpos"/>
  122.                         <xsl:with-param name="count" select="2"/>
  123.                     </xsl:call-template>
  124.                 </xsl:variable>
  125.                 <xsl:call-template name="vmlpath2svgpath">
  126.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  127.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  128.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  129.                     <xsl:with-param name="last-command" select="$command"/>
  130.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  131.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  132.                 </xsl:call-template>
  133.             </xsl:when>
  134.             <xsl:when test="$command = 'r' ">
  135.                 <!-- relative lineto -->
  136.                 <!-- 'l' command is not supported currently, so we use 'L' -->
  137.                 <xsl:message>'l' command is not supported currently, so we use 'L'. This may case problem.</xsl:message>
  138.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' L ' ) "/>
  139.                 <xsl:variable name="num-and-pos">
  140.                     <xsl:call-template name="get-number-after">
  141.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  142.                         <xsl:with-param name="position" select="$newpos"/>
  143.                         <xsl:with-param name="count" select="2"/>
  144.                     </xsl:call-template>
  145.                 </xsl:variable>
  146.                 <xsl:variable name="new-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  147.                 <xsl:variable name="new-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  148.                 <xsl:call-template name="vmlpath2svgpath">
  149.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  150.                     <!-- 'l' command is not supported currently-->
  151.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , $new-x ,' ' , $new-y  , ' ') "/>
  152.                     <!-- xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/ -->
  153.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  154.                     <xsl:with-param name="last-command" select="$command"/>
  155.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  156.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  157.                 </xsl:call-template>
  158.             </xsl:when>
  159.             <xsl:when test="$command = 'dummyH' ">
  160.                 <!-- absolute horizontal  lineto -->
  161.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  162.                 <xsl:variable name="num-and-pos">
  163.                     <xsl:call-template name="get-number-after">
  164.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  165.                         <xsl:with-param name="position" select="$newpos"/>
  166.                         <xsl:with-param name="count" select="1"/>
  167.                     </xsl:call-template>
  168.                 </xsl:variable>
  169.                 <xsl:call-template name="vmlpath2svgpath">
  170.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  171.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ' , $current-y , ' ') "/>
  172.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  173.                     <xsl:with-param name="last-command" select="$command"/>
  174.                     <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':')  "/>
  175.                     <xsl:with-param name="current-y" select=" $current-y"/>
  176.                 </xsl:call-template>
  177.             </xsl:when>
  178.             <xsl:when test="$command = 'dummyh' ">
  179.                 <!-- relative horizontal  lineto -->
  180.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  181.                 <xsl:variable name="num-and-pos">
  182.                     <xsl:call-template name="get-number-after">
  183.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  184.                         <xsl:with-param name="position" select="$newpos"/>
  185.                         <xsl:with-param name="count" select="1"/>
  186.                     </xsl:call-template>
  187.                 </xsl:variable>
  188.                 <xsl:call-template name="vmlpath2svgpath">
  189.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  190.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':') + $current-x  , ' ' , $current-y , ' ') "/>
  191.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  192.                     <xsl:with-param name="last-command" select="$command"/>
  193.                     <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':')  + $current-x"/>
  194.                     <xsl:with-param name="current-y" select=" $current-y"/>
  195.                 </xsl:call-template>
  196.             </xsl:when>
  197.             <xsl:when test="$command = 'dummyV' ">
  198.                 <!-- absolute vertical  lineto -->
  199.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  200.                 <xsl:variable name="num-and-pos">
  201.                     <xsl:call-template name="get-number-after">
  202.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  203.                         <xsl:with-param name="position" select="$newpos"/>
  204.                         <xsl:with-param name="count" select="1"/>
  205.                     </xsl:call-template>
  206.                 </xsl:variable>
  207.                 <xsl:call-template name="vmlpath2svgpath">
  208.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  209.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , $current-x , ' ' , substring-before( $num-and-pos , ':')  , ' ' ) "/>
  210.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  211.                     <xsl:with-param name="last-command" select="$command"/>
  212.                     <xsl:with-param name="current-x" select=" $current-x"/>
  213.                     <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':')  "/>
  214.                 </xsl:call-template>
  215.             </xsl:when>
  216.             <xsl:when test="$command = 'dummyv' ">
  217.                 <!-- relative horizontal  lineto -->
  218.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  219.                 <xsl:variable name="num-and-pos">
  220.                     <xsl:call-template name="get-number-after">
  221.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  222.                         <xsl:with-param name="position" select="$newpos"/>
  223.                         <xsl:with-param name="count" select="1"/>
  224.                     </xsl:call-template>
  225.                 </xsl:variable>
  226.                 <xsl:call-template name="vmlpath2svgpath">
  227.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  228.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , $current-x , ' ' , substring-before( $num-and-pos , ':')  + $current-y , ' ' ) "/>
  229.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  230.                     <xsl:with-param name="last-command" select="$command"/>
  231.                     <xsl:with-param name="current-x" select=" $current-x"/>
  232.                     <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':')  "/>
  233.                 </xsl:call-template>
  234.             </xsl:when>
  235.             <xsl:when test="$command = 'c' ">
  236.                 <!-- absolute curveto -->
  237.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' C ' ) "/>
  238.                 <xsl:variable name="control-and-pos">
  239.                     <xsl:call-template name="get-number-after">
  240.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  241.                         <xsl:with-param name="position" select="$newpos"/>
  242.                         <xsl:with-param name="count" select="4"/>
  243.                     </xsl:call-template>
  244.                 </xsl:variable>
  245.                 <xsl:variable name="num-and-pos">
  246.                     <xsl:call-template name="get-number-after">
  247.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  248.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  249.                         <xsl:with-param name="count" select="2"/>
  250.                     </xsl:call-template>
  251.                 </xsl:variable>
  252.                 <xsl:call-template name="vmlpath2svgpath">
  253.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  254.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  255.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  256.                     <xsl:with-param name="last-command" select="$command"/>
  257.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  258.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  259.                 </xsl:call-template>
  260.             </xsl:when>
  261.             <xsl:when test="$command = 'v' ">
  262.                 <!-- relative curveto -->
  263.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' c ' ) "/>
  264.                 <xsl:variable name="control-and-pos">
  265.                     <xsl:call-template name="get-number-after">
  266.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  267.                         <xsl:with-param name="position" select="$newpos"/>
  268.                         <xsl:with-param name="count" select="4"/>
  269.                     </xsl:call-template>
  270.                 </xsl:variable>
  271.                 <xsl:variable name="num-and-pos">
  272.                     <xsl:call-template name="get-number-after">
  273.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  274.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  275.                         <xsl:with-param name="count" select="2"/>
  276.                     </xsl:call-template>
  277.                 </xsl:variable>
  278.                 <xsl:call-template name="vmlpath2svgpath">
  279.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  280.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  281.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  282.                     <xsl:with-param name="last-command" select="$command"/>
  283.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  284.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  285.                 </xsl:call-template>
  286.             </xsl:when>
  287.             <xsl:when test="$command = 'dummyS' ">
  288.                 <!-- absolute shorthand/smooth curveto -->
  289.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' c ' ) "/>
  290.                 <xsl:variable name="control-and-pos">
  291.                     <xsl:call-template name="get-number-after">
  292.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  293.                         <xsl:with-param name="position" select="$newpos"/>
  294.                         <xsl:with-param name="count" select="2"/>
  295.                     </xsl:call-template>
  296.                 </xsl:variable>
  297.                 <xsl:variable name="num-and-pos">
  298.                     <xsl:call-template name="get-number-after">
  299.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  300.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  301.                         <xsl:with-param name="count" select="2"/>
  302.                     </xsl:call-template>
  303.                 </xsl:variable>
  304.                 <xsl:variable name="control-1">
  305.                     <xsl:choose>
  306.                         <xsl:when test="string-length(translate($last-command, 'CcSs','')  )= 0 ">
  307.                             <xsl:variable name="previous-control-2">
  308.                                 <xsl:call-template name="get-number-before">
  309.                                     <xsl:with-param name="vml-path" select="$vml-path"/>
  310.                                     <xsl:with-param name="position" select="$position"/>
  311.                                     <xsl:with-param name="count" select="2"/>
  312.                                     <xsl:with-param name="skipcount" select="2"/>
  313.                                 </xsl:call-template>
  314.                             </xsl:variable>
  315.                             <xsl:value-of select="substring-before($previous-control-2 , ':') "/>
  316.                         </xsl:when>
  317.                         <xsl:otherwise>
  318.                             <xsl:value-of select="substring-before($control-and-pos, ':') "/>
  319.                         </xsl:otherwise>
  320.                     </xsl:choose>
  321.                 </xsl:variable>
  322.                 <xsl:call-template name="vmlpath2svgpath">
  323.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  324.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path ,  $control-1 , ' ' ,  substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  325.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  326.                     <xsl:with-param name="last-command" select="$command"/>
  327.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  328.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  329.                 </xsl:call-template>
  330.             </xsl:when>
  331.             <xsl:when test="$command = 'dummys' ">
  332.                 <!-- absolute shorthand/smooth curveto -->
  333.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' v ' ) "/>
  334.                 <xsl:variable name="control-and-pos">
  335.                     <xsl:call-template name="get-number-after">
  336.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  337.                         <xsl:with-param name="position" select="$newpos"/>
  338.                         <xsl:with-param name="count" select="2"/>
  339.                     </xsl:call-template>
  340.                 </xsl:variable>
  341.                 <xsl:variable name="num-and-pos">
  342.                     <xsl:call-template name="get-number-after">
  343.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  344.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  345.                         <xsl:with-param name="count" select="2"/>
  346.                     </xsl:call-template>
  347.                 </xsl:variable>
  348.                 <xsl:variable name="control-1">
  349.                     <xsl:choose>
  350.                         <xsl:when test="string-length(translate($last-command, 'CcSs' , '')) = 0 ">
  351.                             <xsl:variable name="previous-control-2">
  352.                                 <xsl:call-template name="get-number-before">
  353.                                     <xsl:with-param name="vml-path" select="$vml-path"/>
  354.                                     <xsl:with-param name="position" select="$position"/>
  355.                                     <xsl:with-param name="count" select="2"/>
  356.                                     <xsl:with-param name="skipcount" select="2"/>
  357.                                 </xsl:call-template>
  358.                             </xsl:variable>
  359.                             <xsl:value-of select="substring-before($previous-control-2 , ':') "/>
  360.                         </xsl:when>
  361.                         <xsl:otherwise>
  362.                             <xsl:value-of select="substring-before($control-and-pos, ':') "/>
  363.                         </xsl:otherwise>
  364.                     </xsl:choose>
  365.                 </xsl:variable>
  366.                 <xsl:call-template name="vmlpath2svgpath">
  367.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  368.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path ,  $control-1 , ' ' ,  substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  369.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  370.                     <xsl:with-param name="last-command" select="$command"/>
  371.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  372.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  373.                 </xsl:call-template>
  374.             </xsl:when>
  375.             <xsl:when test="$command = 'dummyQ' ">
  376.                 <!-- absolute quadratic  b├⌐zier curves  -->
  377.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' qb ' ) "/>
  378.                 <xsl:variable name="control-and-pos">
  379.                     <xsl:call-template name="get-number-after">
  380.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  381.                         <xsl:with-param name="position" select="$newpos"/>
  382.                         <xsl:with-param name="count" select="2"/>
  383.                     </xsl:call-template>
  384.                 </xsl:variable>
  385.                 <xsl:variable name="num-and-pos">
  386.                     <xsl:call-template name="get-number-after">
  387.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  388.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  389.                         <xsl:with-param name="count" select="2"/>
  390.                     </xsl:call-template>
  391.                 </xsl:variable>
  392.                 <xsl:call-template name="vmlpath2svgpath">
  393.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  394.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  395.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  396.                     <xsl:with-param name="last-command" select="$command"/>
  397.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  398.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  399.                 </xsl:call-template>
  400.             </xsl:when>
  401.             <xsl:when test="$command = 'dummyq' ">
  402.                 <!-- relative  quadratic  b├⌐zier curves -->
  403.                 <xsl:variable name="control-and-pos">
  404.                     <xsl:call-template name="get-number-after">
  405.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  406.                         <xsl:with-param name="position" select="$newpos"/>
  407.                         <xsl:with-param name="count" select="2"/>
  408.                     </xsl:call-template>
  409.                 </xsl:variable>
  410.                 <xsl:variable name="control" select="substring-before( $control-and-pos , ':') "/>
  411.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' qb ' ,  substring-before($control,' ') + $current-x , ' '  , substring-after($control , ' ') + $current-y ) "/>
  412.                 <xsl:variable name="num-and-pos">
  413.                     <xsl:call-template name="get-number-after">
  414.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  415.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  416.                         <xsl:with-param name="count" select="2"/>
  417.                     </xsl:call-template>
  418.                 </xsl:variable>
  419.                 <xsl:variable name="number" select="substring-before($num-and-pos, ':')"/>
  420.                 <xsl:variable name="absolute-number" select="concat(substring-before($number, ' ') + $current-x  , ' ' , substring-after($number, ' ') + $current-y)"/>
  421.                 <xsl:call-template name="vmlpath2svgpath">
  422.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  423.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path   , ' ' ,  $absolute-number  , ' ') "/>
  424.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  425.                     <xsl:with-param name="last-command" select="$command"/>
  426.                     <xsl:with-param name="current-x" select=" substring-before( $absolute-number  , ' ') "/>
  427.                     <xsl:with-param name="current-y" select=" substring-after( $absolute-number   , ' ') "/>
  428.                 </xsl:call-template>
  429.             </xsl:when>
  430.             <xsl:when test="$command = 'x' ">
  431.                 <!--dummy or $command = 'z' "-->
  432.                 <!-- closepath -->
  433.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' Z ' ) "/>
  434.                 <xsl:call-template name="vmlpath2svgpath">
  435.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  436.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  437.                     <xsl:with-param name="position" select=" $newpos  "/>
  438.                     <xsl:with-param name="last-command" select="$command"/>
  439.                     <xsl:with-param name="current-x" select=" $current-x "/>
  440.                     <xsl:with-param name="current-y" select=" $current-y"/>
  441.                 </xsl:call-template>
  442.             </xsl:when>
  443.             <xsl:when test="$command = 'e' ">
  444.                 <!-- end path -->
  445.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' N ' )"/>
  446.                 <xsl:call-template name="vmlpath2svgpath">
  447.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  448.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  449.                     <xsl:with-param name="position" select=" $newpos  "/>
  450.                     <xsl:with-param name="last-command" select="$command"/>
  451.                     <xsl:with-param name="current-x" select=" $current-x "/>
  452.                     <xsl:with-param name="current-y" select=" $current-y"/>
  453.                 </xsl:call-template>
  454.             </xsl:when>
  455.             <!--Code below is for the support of h-command like ha,hb....hi, maybe still need to revise-->
  456.             <xsl:when test="$command = 'ha' ">
  457.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  458.                 <!--simply did nothing which might be wrong-->
  459.                 <xsl:call-template name="vmlpath2svgpath">
  460.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  461.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  462.                     <xsl:with-param name="position" select=" $newpos  "/>
  463.                     <xsl:with-param name="last-command" select="$command"/>
  464.                     <xsl:with-param name="current-x" select=" $current-x "/>
  465.                     <xsl:with-param name="current-y" select=" $current-y"/>
  466.                 </xsl:call-template>
  467.             </xsl:when>
  468.             <xsl:when test="$command = 'hb' ">
  469.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  470.                 <!--simply did nothing which might be wrong-->
  471.                 <xsl:call-template name="vmlpath2svgpath">
  472.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  473.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  474.                     <xsl:with-param name="position" select=" $newpos  "/>
  475.                     <xsl:with-param name="last-command" select="$command"/>
  476.                     <xsl:with-param name="current-x" select=" $current-x "/>
  477.                     <xsl:with-param name="current-y" select=" $current-y"/>
  478.                 </xsl:call-template>
  479.             </xsl:when>
  480.             <xsl:when test="$command = 'hc' ">
  481.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  482.                 <!--simply did nothing which might be wrong-->
  483.                 <xsl:call-template name="vmlpath2svgpath">
  484.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  485.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  486.                     <xsl:with-param name="position" select=" $newpos  "/>
  487.                     <xsl:with-param name="last-command" select="$command"/>
  488.                     <xsl:with-param name="current-x" select=" $current-x "/>
  489.                     <xsl:with-param name="current-y" select=" $current-y"/>
  490.                 </xsl:call-template>
  491.             </xsl:when>
  492.             <xsl:when test="$command = 'hd' ">
  493.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  494.                 <!--simply did nothing which might be wrong-->
  495.                 <xsl:call-template name="vmlpath2svgpath">
  496.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  497.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  498.                     <xsl:with-param name="position" select=" $newpos  "/>
  499.                     <xsl:with-param name="last-command" select="$command"/>
  500.                     <xsl:with-param name="current-x" select=" $current-x "/>
  501.                     <xsl:with-param name="current-y" select=" $current-y"/>
  502.                 </xsl:call-template>
  503.             </xsl:when>
  504.             <xsl:when test="$command = 'he' ">
  505.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  506.                 <!--simply did nothing which might be wrong-->
  507.                 <xsl:call-template name="vmlpath2svgpath">
  508.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  509.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  510.                     <xsl:with-param name="position" select=" $newpos  "/>
  511.                     <xsl:with-param name="last-command" select="$command"/>
  512.                     <xsl:with-param name="current-x" select=" $current-x "/>
  513.                     <xsl:with-param name="current-y" select=" $current-y"/>
  514.                 </xsl:call-template>
  515.             </xsl:when>
  516.             <xsl:when test="$command = 'hf' ">
  517.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  518.                 <!--simply did nothing which might be wrong-->
  519.                 <xsl:call-template name="vmlpath2svgpath">
  520.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  521.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  522.                     <xsl:with-param name="position" select=" $newpos  "/>
  523.                     <xsl:with-param name="last-command" select="$command"/>
  524.                     <xsl:with-param name="current-x" select=" $current-x "/>
  525.                     <xsl:with-param name="current-y" select=" $current-y"/>
  526.                 </xsl:call-template>
  527.             </xsl:when>
  528.             <xsl:when test="$command = 'hg' ">
  529.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  530.                 <!--simply did nothing which might be wrong-->
  531.                 <xsl:call-template name="vmlpath2svgpath">
  532.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  533.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  534.                     <xsl:with-param name="position" select=" $newpos  "/>
  535.                     <xsl:with-param name="last-command" select="$command"/>
  536.                     <xsl:with-param name="current-x" select=" $current-x "/>
  537.                     <xsl:with-param name="current-y" select=" $current-y"/>
  538.                 </xsl:call-template>
  539.             </xsl:when>
  540.             <xsl:when test="$command = 'hh' ">
  541.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  542.                 <!--simply did nothing which might be wrong-->
  543.                 <xsl:call-template name="vmlpath2svgpath">
  544.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  545.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  546.                     <xsl:with-param name="position" select=" $newpos  "/>
  547.                     <xsl:with-param name="last-command" select="$command"/>
  548.                     <xsl:with-param name="current-x" select=" $current-x "/>
  549.                     <xsl:with-param name="current-y" select=" $current-y"/>
  550.                 </xsl:call-template>
  551.             </xsl:when>
  552.             <xsl:when test="$command = 'hi' ">
  553.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  554.                 <!--simply did nothing which might be wrong-->
  555.                 <xsl:call-template name="vmlpath2svgpath">
  556.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  557.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  558.                     <xsl:with-param name="position" select=" $newpos  "/>
  559.                     <xsl:with-param name="last-command" select="$command"/>
  560.                     <xsl:with-param name="current-x" select=" $current-x "/>
  561.                     <xsl:with-param name="current-y" select=" $current-y"/>
  562.                 </xsl:call-template>
  563.             </xsl:when>
  564.             <xsl:when test="$command = 'nf' or $command = 'ns' ">
  565.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  566.                 <!--simply did nothing which might be wrong-->
  567.                 <xsl:call-template name="vmlpath2svgpath">
  568.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  569.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  570.                     <xsl:with-param name="position" select=" $newpos  "/>
  571.                     <xsl:with-param name="last-command" select="$command"/>
  572.                     <xsl:with-param name="current-x" select=" $current-x "/>
  573.                     <xsl:with-param name="current-y" select=" $current-y"/>
  574.                 </xsl:call-template>
  575.             </xsl:when>
  576.             <xsl:when test="$command = 'al' ">
  577.                 <!-- absolute moveto -->
  578.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' W ' ) "/>
  579.                 <xsl:variable name="num-and-pos">
  580.                     <xsl:call-template name="get-number-after">
  581.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  582.                         <xsl:with-param name="position" select="$newpos"/>
  583.                         <xsl:with-param name="count" select="6"/>
  584.                     </xsl:call-template>
  585.                 </xsl:variable>
  586.                 <xsl:call-template name="vmlpath2svgpath">
  587.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  588.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  589.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  590.                     <xsl:with-param name="last-command" select="$command"/>
  591.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  592.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  593.                 </xsl:call-template>
  594.             </xsl:when>
  595.             <xsl:otherwise>
  596.                 <xsl:value-of select="$svg-path"/>
  597.             </xsl:otherwise>
  598.         </xsl:choose>
  599.     </xsl:template>
  600.     <!-- 
  601.     **Template vmlpath2enhancedpath**
  602.     The template is resposible for converting the vml-path to enhanced-path, because the svg:path 
  603.     cann't support command a now.(But heard that will be supported in OOo3.0)
  604.     And  the 2nd reason of using an enhanced-path is that enhanced-path have a perfect maping to 
  605.     vmlpath.(You will find out that often,we  even don't need to change the parameters).
  606.     -->
  607.     <xsl:template name="vmlpath2enhancedpath">
  608.         <xsl:param name="vml-path"/>
  609.         <xsl:param name="enhanced-path" select="''"/>
  610.         <xsl:param name="position" select="1"/>
  611.         <xsl:param name="last-command" select="'m'"/>
  612.         <xsl:param name="current-x" select="'0'"/>
  613.         <xsl:param name="current-y" select="'0'"/>
  614.         <xsl:variable name="command-and-newpos">
  615.             <xsl:call-template name="get-path-command">
  616.                 <xsl:with-param name="vml-path" select="$vml-path"/>
  617.                 <xsl:with-param name="position" select="$position"/>
  618.                 <xsl:with-param name="last-command" select="$last-command"/>
  619.             </xsl:call-template>
  620.         </xsl:variable>
  621.         <xsl:variable name="command" select="substring-before($command-and-newpos , ':')"/>
  622.         <xsl:variable name="newpos" select="substring-after($command-and-newpos , ':')"/>
  623.         <xsl:choose>
  624.             <xsl:when test="$command = 'm' ">
  625.                 <!--####Notice that the "m 0,0,1,1,1,1" means two lines-->
  626.                 <!-- absolute moveto -->
  627.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' M ' ) "/>
  628.                 <xsl:variable name="num-and-pos">
  629.                     <xsl:call-template name="get-number-after">
  630.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  631.                         <xsl:with-param name="position" select="$newpos"/>
  632.                         <xsl:with-param name="count" select="2"/>
  633.                     </xsl:call-template>
  634.                 </xsl:variable>
  635.                 <xsl:call-template name="vmlpath2enhancedpath">
  636.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  637.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  638.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  639.                     <xsl:with-param name="last-command" select="$command"/>
  640.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  641.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  642.                 </xsl:call-template>
  643.             </xsl:when>
  644.             <xsl:when test="$command = 'l' ">
  645.                 <!-- absolute lineto -->
  646.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' L ' ) "/>
  647.                 <xsl:variable name="num-and-pos">
  648.                     <xsl:call-template name="get-number-after">
  649.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  650.                         <xsl:with-param name="position" select="$newpos"/>
  651.                         <xsl:with-param name="count" select="2"/>
  652.                     </xsl:call-template>
  653.                 </xsl:variable>
  654.                 <xsl:call-template name="vmlpath2enhancedpath">
  655.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  656.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  657.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  658.                     <xsl:with-param name="last-command" select="$command"/>
  659.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  660.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  661.                 </xsl:call-template>
  662.             </xsl:when>
  663.             <xsl:when test="$command = 'x' ">
  664.                 <!--dummy or $command = 'z' "-->
  665.                 <!-- closepath -->
  666.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' Z ' ) "/>
  667.                 <xsl:call-template name="vmlpath2enhancedpath">
  668.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  669.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  670.                     <xsl:with-param name="position" select=" $newpos  "/>
  671.                     <xsl:with-param name="last-command" select="$command"/>
  672.                     <xsl:with-param name="current-x" select=" $current-x "/>
  673.                     <xsl:with-param name="current-y" select=" $current-y"/>
  674.                 </xsl:call-template>
  675.             </xsl:when>
  676.             <xsl:when test="$command = 'e' ">
  677.                 <!-- end path -->
  678.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' N ' )"/>
  679.                 <xsl:call-template name="vmlpath2enhancedpath">
  680.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  681.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  682.                     <xsl:with-param name="position" select=" $newpos  "/>
  683.                     <xsl:with-param name="last-command" select="$command"/>
  684.                     <xsl:with-param name="current-x" select=" $current-x "/>
  685.                     <xsl:with-param name="current-y" select=" $current-y"/>
  686.                 </xsl:call-template>
  687.             </xsl:when>
  688.             <xsl:when test="$command = 'c' ">
  689.                 <!-- absolute curveto -->
  690.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' C ' ) "/>
  691.                 <xsl:variable name="control-and-pos">
  692.                     <xsl:call-template name="get-number-after">
  693.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  694.                         <xsl:with-param name="position" select="$newpos"/>
  695.                         <xsl:with-param name="count" select="4"/>
  696.                     </xsl:call-template>
  697.                 </xsl:variable>
  698.                 <xsl:variable name="num-and-pos">
  699.                     <xsl:call-template name="get-number-after">
  700.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  701.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  702.                         <xsl:with-param name="count" select="2"/>
  703.                     </xsl:call-template>
  704.                 </xsl:variable>
  705.                 <xsl:call-template name="vmlpath2enhancedpath">
  706.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  707.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  708.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  709.                     <xsl:with-param name="last-command" select="$command"/>
  710.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  711.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  712.                 </xsl:call-template>
  713.             </xsl:when>
  714.             <xsl:when test="$command = 't' ">
  715.                 <!-- relative moveto -->
  716.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' M ' ) "/>
  717.                 <!--####maybe this is not crect because t r and v hasn't direct image in enhaced-path-->
  718.                 <xsl:variable name="num-and-pos">
  719.                     <xsl:call-template name="get-number-after">
  720.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  721.                         <xsl:with-param name="position" select="$newpos"/>
  722.                         <xsl:with-param name="count" select="2"/>
  723.                     </xsl:call-template>
  724.                 </xsl:variable>
  725.                 <xsl:call-template name="vmlpath2enhancedpath">
  726.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  727.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  728.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  729.                     <xsl:with-param name="last-command" select="$command"/>
  730.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')    , ' ')  + $current-x"/>
  731.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ') + $current-y "/>
  732.                 </xsl:call-template>
  733.             </xsl:when>
  734.             <xsl:when test="$command = 'r' ">
  735.                 <!-- relative lineto -->
  736.                 <!--####maybe this is not crect because 't' 'r' and 'v' hasn't direct image in enhaced-path-->
  737.                 <!-- 'l' command is not supported currently, so we use 'L' -->
  738.                 <xsl:message>'l' command is not supported currently, so we use 'L'. This may case problem.</xsl:message>
  739.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' L ' ) "/>
  740.                 <xsl:variable name="num-and-pos">
  741.                     <xsl:call-template name="get-number-after">
  742.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  743.                         <xsl:with-param name="position" select="$newpos"/>
  744.                         <xsl:with-param name="count" select="2"/>
  745.                     </xsl:call-template>
  746.                 </xsl:variable>
  747.                 <xsl:variable name="new-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  748.                 <xsl:variable name="new-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  749.                 <xsl:call-template name="vmlpath2enhancedpath">
  750.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  751.                     <!-- 'l' command is not supported currently-->
  752.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , $new-x ,' ' , $new-y  , ' ') "/>
  753.                     <!-- xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/ -->
  754.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  755.                     <xsl:with-param name="last-command" select="$command"/>
  756.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  757.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  758.                 </xsl:call-template>
  759.             </xsl:when>
  760.             <xsl:when test="$command = 'v' ">
  761.                 <!-- relative curveto -->
  762.                 <!--####maybe this is not crect because 't' 'r' and 'v' hasn't direct image in enhaced-path-->
  763.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' C ' ) "/>
  764.                 <!--<xsl:variable name="control-and-pos">
  765.                     <xsl:call-template name="get-number-after">
  766.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  767.                         <xsl:with-param name="position" select="$newpos"/>
  768.                         <xsl:with-param name="count" select="4"/>
  769.                     </xsl:call-template>
  770.                 </xsl:variable>
  771.                 <xsl:variable name="num-and-pos">
  772.                     <xsl:call-template name="get-number-after">
  773.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  774.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  775.                         <xsl:with-param name="count" select="2"/>
  776.                     </xsl:call-template>
  777.                 </xsl:variable>
  778.                 <xsl:call-template name="vmlpath2enhancedpath">
  779.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  780.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  781.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  782.                     <xsl:with-param name="last-command" select="$command"/>
  783.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  784.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  785.                 </xsl:call-template>-
  786.                 -->
  787.                 <xsl:variable name="x1">
  788.                     <xsl:call-template name="get-number-after">
  789.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  790.                         <xsl:with-param name="position" select="$newpos"/>
  791.                         <xsl:with-param name="count" select="1"/>
  792.                     </xsl:call-template>
  793.                 </xsl:variable>
  794.                 <xsl:variable name="y1">
  795.                     <xsl:call-template name="get-number-after">
  796.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  797.                         <xsl:with-param name="position" select="substring-after( $x1 , ':')"/>
  798.                         <xsl:with-param name="count" select="1"/>
  799.                     </xsl:call-template>
  800.                 </xsl:variable>
  801.                 <xsl:variable name="x2">
  802.                     <xsl:call-template name="get-number-after">
  803.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  804.                         <xsl:with-param name="position" select="substring-after( $y1 , ':')"/>
  805.                         <xsl:with-param name="count" select="1"/>
  806.                     </xsl:call-template>
  807.                 </xsl:variable>
  808.                 <xsl:variable name="y2">
  809.                     <xsl:call-template name="get-number-after">
  810.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  811.                         <xsl:with-param name="position" select="substring-after( $x2 , ':')"/>
  812.                         <xsl:with-param name="count" select="1"/>
  813.                     </xsl:call-template>
  814.                 </xsl:variable>
  815.                 <xsl:variable name="x">
  816.                     <xsl:call-template name="get-number-after">
  817.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  818.                         <xsl:with-param name="position" select="substring-after( $y2 , ':')"/>
  819.                         <xsl:with-param name="count" select="1"/>
  820.                     </xsl:call-template>
  821.                 </xsl:variable>
  822.                 <xsl:variable name="y">
  823.                     <xsl:call-template name="get-number-after">
  824.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  825.                         <xsl:with-param name="position" select="substring-after( $x , ':')"/>
  826.                         <xsl:with-param name="count" select="1"/>
  827.                     </xsl:call-template>
  828.                 </xsl:variable>
  829.                 <xsl:variable name="val_x1">
  830.                     <xsl:value-of select="substring-before( $x1 , ':')+$current-x"/>
  831.                 </xsl:variable>
  832.                 <xsl:variable name="val_y1">
  833.                     <xsl:value-of select="substring-before( $y1 , ':')+$current-y"/>
  834.                 </xsl:variable>
  835.                 <xsl:variable name="val_x2">
  836.                     <xsl:value-of select="substring-before( $x2 , ':')+$current-x"/>
  837.                 </xsl:variable>
  838.                 <xsl:variable name="val_y2">
  839.                     <xsl:value-of select="substring-before( $y2 , ':')+$current-y"/>
  840.                 </xsl:variable>
  841.                 <xsl:variable name="val_x">
  842.                     <xsl:value-of select="substring-before( $x , ':')+$current-x"/>
  843.                 </xsl:variable>
  844.                 <xsl:variable name="val_y">
  845.                     <xsl:value-of select="substring-before( $y , ':')+$current-y"/>
  846.                 </xsl:variable>
  847.                 <xsl:variable name="control-and-pos">
  848.                     <xsl:value-of select="concat($val_x1, ' ',$val_y1, ' ',$val_x2, ' ',$val_y2, ' ' )"/>
  849.                 </xsl:variable>
  850.                 <xsl:variable name="num-and-pos">
  851.                     <xsl:value-of select="concat($val_x, ' ',$val_y, ' ' )"/>
  852.                 </xsl:variable>
  853.                 <xsl:call-template name="vmlpath2enhancedpath">
  854.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  855.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ',$control-and-pos , ' ' , $num-and-pos , ' ') "/>
  856.                     <xsl:with-param name="position" select=" substring-after( $y , ':')  "/>
  857.                     <xsl:with-param name="last-command" select="$command"/>
  858.                     <xsl:with-param name="current-x" select=" $val_x  "/>
  859.                     <xsl:with-param name="current-y" select=" $val_y "/>
  860.                 </xsl:call-template>
  861.             </xsl:when>
  862.             <!--Code below is for the support of h-command like ha,hb....hi, maybe still need to revise-->
  863.             <xsl:when test="$command = 'ha' ">
  864.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  865.                 <!--simply did nothing which might be wrong-->
  866.                 <xsl:call-template name="vmlpath2enhancedpath">
  867.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  868.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  869.                     <xsl:with-param name="position" select=" $newpos  "/>
  870.                     <xsl:with-param name="last-command" select="$command"/>
  871.                     <xsl:with-param name="current-x" select=" $current-x "/>
  872.                     <xsl:with-param name="current-y" select=" $current-y"/>
  873.                 </xsl:call-template>
  874.             </xsl:when>
  875.             <xsl:when test="$command = 'hb' ">
  876.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  877.                 <!--simply did nothing which might be wrong-->
  878.                 <xsl:call-template name="vmlpath2enhancedpath">
  879.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  880.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  881.                     <xsl:with-param name="position" select=" $newpos  "/>
  882.                     <xsl:with-param name="last-command" select="$command"/>
  883.                     <xsl:with-param name="current-x" select=" $current-x "/>
  884.                     <xsl:with-param name="current-y" select=" $current-y"/>
  885.                 </xsl:call-template>
  886.             </xsl:when>
  887.             <xsl:when test="$command = 'hc' ">
  888.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  889.                 <!--simply did nothing which might be wrong-->
  890.                 <xsl:call-template name="vmlpath2enhancedpath">
  891.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  892.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  893.                     <xsl:with-param name="position" select=" $newpos  "/>
  894.                     <xsl:with-param name="last-command" select="$command"/>
  895.                     <xsl:with-param name="current-x" select=" $current-x "/>
  896.                     <xsl:with-param name="current-y" select=" $current-y"/>
  897.                 </xsl:call-template>
  898.             </xsl:when>
  899.             <xsl:when test="$command = 'hd' ">
  900.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  901.                 <!--simply did nothing which might be wrong-->
  902.                 <xsl:call-template name="vmlpath2enhancedpath">
  903.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  904.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  905.                     <xsl:with-param name="position" select=" $newpos  "/>
  906.                     <xsl:with-param name="last-command" select="$command"/>
  907.                     <xsl:with-param name="current-x" select=" $current-x "/>
  908.                     <xsl:with-param name="current-y" select=" $current-y"/>
  909.                 </xsl:call-template>
  910.             </xsl:when>
  911.             <xsl:when test="$command = 'he' ">
  912.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  913.                 <!--simply did nothing which might be wrong-->
  914.                 <xsl:call-template name="vmlpath2enhancedpath">
  915.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  916.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  917.                     <xsl:with-param name="position" select=" $newpos  "/>
  918.                     <xsl:with-param name="last-command" select="$command"/>
  919.                     <xsl:with-param name="current-x" select=" $current-x "/>
  920.                     <xsl:with-param name="current-y" select=" $current-y"/>
  921.                 </xsl:call-template>
  922.             </xsl:when>
  923.             <xsl:when test="$command = 'hf' ">
  924.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  925.                 <!--simply did nothing which might be wrong-->
  926.                 <xsl:call-template name="vmlpath2enhancedpath">
  927.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  928.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  929.                     <xsl:with-param name="position" select=" $newpos  "/>
  930.                     <xsl:with-param name="last-command" select="$command"/>
  931.                     <xsl:with-param name="current-x" select=" $current-x "/>
  932.                     <xsl:with-param name="current-y" select=" $current-y"/>
  933.                 </xsl:call-template>
  934.             </xsl:when>
  935.             <xsl:when test="$command = 'hg' ">
  936.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  937.                 <!--simply did nothing which might be wrong-->
  938.                 <xsl:call-template name="vmlpath2enhancedpath">
  939.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  940.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  941.                     <xsl:with-param name="position" select=" $newpos  "/>
  942.                     <xsl:with-param name="last-command" select="$command"/>
  943.                     <xsl:with-param name="current-x" select=" $current-x "/>
  944.                     <xsl:with-param name="current-y" select=" $current-y"/>
  945.                 </xsl:call-template>
  946.             </xsl:when>
  947.             <xsl:when test="$command = 'hh' ">
  948.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  949.                 <!--simply did nothing which might be wrong-->
  950.                 <xsl:call-template name="vmlpath2enhancedpath">
  951.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  952.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  953.                     <xsl:with-param name="position" select=" $newpos  "/>
  954.                     <xsl:with-param name="last-command" select="$command"/>
  955.                     <xsl:with-param name="current-x" select=" $current-x "/>
  956.                     <xsl:with-param name="current-y" select=" $current-y"/>
  957.                 </xsl:call-template>
  958.             </xsl:when>
  959.             <xsl:when test="$command = 'hi' ">
  960.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  961.                 <!--simply did nothing which might be wrong-->
  962.                 <xsl:call-template name="vmlpath2enhancedpath">
  963.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  964.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  965.                     <xsl:with-param name="position" select=" $newpos  "/>
  966.                     <xsl:with-param name="last-command" select="$command"/>
  967.                     <xsl:with-param name="current-x" select=" $current-x "/>
  968.                     <xsl:with-param name="current-y" select=" $current-y"/>
  969.                 </xsl:call-template>
  970.             </xsl:when>
  971.             <xsl:when test="$command = 'nf' ">
  972.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' F ' )"/>
  973.                 <!--simply did nothing which might be wrong-->
  974.                 <xsl:call-template name="vmlpath2enhancedpath">
  975.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  976.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  977.                     <xsl:with-param name="position" select=" $newpos  "/>
  978.                     <xsl:with-param name="last-command" select="$command"/>
  979.                     <xsl:with-param name="current-x" select=" $current-x "/>
  980.                     <xsl:with-param name="current-y" select=" $current-y"/>
  981.                 </xsl:call-template>
  982.             </xsl:when>
  983.             <xsl:when test="$command = 'ns' ">
  984.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' S ' )"/>
  985.                 <!--simply did nothing which might be wrong-->
  986.                 <xsl:call-template name="vmlpath2enhancedpath">
  987.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  988.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  989.                     <xsl:with-param name="position" select=" $newpos  "/>
  990.                     <xsl:with-param name="last-command" select="$command"/>
  991.                     <xsl:with-param name="current-x" select=" $current-x "/>
  992.                     <xsl:with-param name="current-y" select=" $current-y"/>
  993.                 </xsl:call-template>
  994.             </xsl:when>
  995.             <!--The following is 6 command which deal with arcs:
  996.                 ae   ->T        al -> U
  997.                 at   -> A        ar  -> B
  998.                 wa -> W     wr  ->V 
  999.               These pairs of commands have shown the perfect mapping from vml-path to enhanced-path-->
  1000.             <xsl:when test="$command = 'ae' ">
  1001.                 <!-- arc on the screen with the start and end angles -->
  1002.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' T ' ) "/>
  1003.                 <xsl:variable name="num-and-pos">
  1004.                     <xsl:call-template name="get-number-after">
  1005.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1006.                         <xsl:with-param name="position" select="$newpos"/>
  1007.                         <xsl:with-param name="count" select="6"/>
  1008.                     </xsl:call-template>
  1009.                 </xsl:variable>
  1010.                 <xsl:call-template name="vmlpath2enhancedpath">
  1011.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1012.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1013.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1014.                     <xsl:with-param name="last-command" select="$command"/>
  1015.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1016.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1017.                 </xsl:call-template>
  1018.             </xsl:when>
  1019.             <xsl:when test="$command = 'al' ">
  1020.                 <!-- ae command plus a implicitly moveto startpoint-->
  1021.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' U ' ) "/>
  1022.                 <xsl:variable name="num-and-pos">
  1023.                     <xsl:call-template name="get-number-after">
  1024.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1025.                         <xsl:with-param name="position" select="$newpos"/>
  1026.                         <xsl:with-param name="count" select="6"/>
  1027.                     </xsl:call-template>
  1028.                 </xsl:variable>
  1029.                 <xsl:call-template name="vmlpath2enhancedpath">
  1030.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1031.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1032.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1033.                     <xsl:with-param name="last-command" select="$command"/>
  1034.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1035.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1036.                 </xsl:call-template>
  1037.             </xsl:when>
  1038.             <xsl:when test="$command = 'at' ">
  1039.                 <!-- arc on the screen with the edge box ,start points and end points(Notice it's counter-clockwise)-->
  1040.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' A ' ) "/>
  1041.                 <xsl:variable name="num-and-pos">
  1042.                     <xsl:call-template name="get-number-after">
  1043.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1044.                         <xsl:with-param name="position" select="$newpos"/>
  1045.                         <xsl:with-param name="count" select="8"/>
  1046.                     </xsl:call-template>
  1047.                 </xsl:variable>
  1048.                 <xsl:call-template name="vmlpath2enhancedpath">
  1049.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1050.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1051.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1052.                     <xsl:with-param name="last-command" select="$command"/>
  1053.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1054.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1055.                 </xsl:call-template>
  1056.             </xsl:when>
  1057.             <xsl:when test="$command = 'ar' ">
  1058.                 <!-- at command plus a implicitly moveto startpoint-->
  1059.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' B ' ) "/>
  1060.                 <xsl:variable name="num-and-pos">
  1061.                     <xsl:call-template name="get-number-after">
  1062.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1063.                         <xsl:with-param name="position" select="$newpos"/>
  1064.                         <xsl:with-param name="count" select="8"/>
  1065.                     </xsl:call-template>
  1066.                 </xsl:variable>
  1067.                 <xsl:call-template name="vmlpath2enhancedpath">
  1068.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1069.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1070.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1071.                     <xsl:with-param name="last-command" select="$command"/>
  1072.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1073.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1074.                 </xsl:call-template>
  1075.             </xsl:when>
  1076.             <xsl:when test="$command = 'wa' ">
  1077.                 <!-- arc on the screen with the edge box ,start points and end points(Notice it's clockwise)-->
  1078.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' W ' ) "/>
  1079.                 <xsl:variable name="num-and-pos">
  1080.                     <xsl:call-template name="get-number-after">
  1081.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1082.                         <xsl:with-param name="position" select="$newpos"/>
  1083.                         <xsl:with-param name="count" select="8"/>
  1084.                     </xsl:call-template>
  1085.                 </xsl:variable>
  1086.                 <xsl:call-template name="vmlpath2enhancedpath">
  1087.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1088.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1089.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1090.                     <xsl:with-param name="last-command" select="$command"/>
  1091.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1092.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1093.                 </xsl:call-template>
  1094.             </xsl:when>
  1095.             <xsl:when test="$command = 'wr' ">
  1096.                 <!-- wa command plus a implicitly moveto startpoint-->
  1097.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' V ' ) "/>
  1098.                 <xsl:variable name="num-and-pos">
  1099.                     <xsl:call-template name="get-number-after">
  1100.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1101.                         <xsl:with-param name="position" select="$newpos"/>
  1102.                         <xsl:with-param name="count" select="8"/>
  1103.                     </xsl:call-template>
  1104.                 </xsl:variable>
  1105.                 <xsl:call-template name="vmlpath2enhancedpath">
  1106.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1107.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1108.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1109.                     <xsl:with-param name="last-command" select="$command"/>
  1110.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1111.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1112.                 </xsl:call-template>
  1113.             </xsl:when>
  1114.             <xsl:when test="$command = 'qx' ">
  1115.                 <!-- Draw a quarter ellipse retated to the x-axis-->
  1116.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' X ' ) "/>
  1117.                 <xsl:variable name="num-and-pos">
  1118.                     <xsl:call-template name="get-number-after">
  1119.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1120.                         <xsl:with-param name="position" select="$newpos"/>
  1121.                         <xsl:with-param name="count" select="2"/>
  1122.                     </xsl:call-template>
  1123.                 </xsl:variable>
  1124.                 <xsl:call-template name="vmlpath2enhancedpath">
  1125.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1126.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1127.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1128.                     <xsl:with-param name="last-command" select="$command"/>
  1129.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1130.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1131.                 </xsl:call-template>
  1132.             </xsl:when>
  1133.             <xsl:when test="$command = 'qy' ">
  1134.                 <!-- Draw a quarter ellipse retated to the y-axis-->
  1135.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' Y ' ) "/>
  1136.                 <xsl:variable name="num-and-pos">
  1137.                     <xsl:call-template name="get-number-after">
  1138.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1139.                         <xsl:with-param name="position" select="$newpos"/>
  1140.                         <xsl:with-param name="count" select="2"/>
  1141.                     </xsl:call-template>
  1142.                 </xsl:variable>
  1143.                 <xsl:call-template name="vmlpath2enhancedpath">
  1144.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1145.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1146.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1147.                     <xsl:with-param name="last-command" select="$command"/>
  1148.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1149.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1150.                 </xsl:call-template>
  1151.             </xsl:when>
  1152.             <xsl:when test="$command = 'qb' ">
  1153.                 <!-- quadratic Bezier-->
  1154.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' Q ' ) "/>
  1155.                 <xsl:variable name="num-and-pos">
  1156.                     <xsl:call-template name="get-number-after">
  1157.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1158.                         <xsl:with-param name="position" select="$newpos"/>
  1159.                         <xsl:with-param name="count" select="4"/>
  1160.                     </xsl:call-template>
  1161.                 </xsl:variable>
  1162.                 <xsl:call-template name="vmlpath2enhancedpath">
  1163.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1164.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1165.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1166.                     <xsl:with-param name="last-command" select="$command"/>
  1167.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1168.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1169.                 </xsl:call-template>
  1170.             </xsl:when>
  1171.             <xsl:otherwise>
  1172.                 <xsl:value-of select="$enhanced-path"/>
  1173.             </xsl:otherwise>
  1174.         </xsl:choose>
  1175.     </xsl:template>
  1176.     <xsl:template name="get-number-before">
  1177.         <!--  get $count number of number before current position , output format:number1 number2 ... numberN:newpostion 
  1178.             skip $skipcount of numbers
  1179.         -->
  1180.         <xsl:param name="vml-path"/>
  1181.         <xsl:param name="position" select="1"/>
  1182.         <xsl:param name="count" select="1"/>
  1183.         <xsl:param name="skipcount" select="0"/>
  1184.         <xsl:param name="number" select="''"/>
  1185.         <xsl:choose>
  1186.             <xsl:when test="$count = 0">
  1187.                 <xsl:value-of select=" concat($number ,   ':' , $position) "/>
  1188.             </xsl:when>
  1189.             <xsl:otherwise>
  1190.                 <xsl:variable name="num-pos">
  1191.                     <xsl:call-template name="get-number-position">
  1192.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1193.                         <xsl:with-param name="position" select="$position"/>
  1194.                         <xsl:with-param name="direction" select="-1"/>
  1195.                     </xsl:call-template>
  1196.                 </xsl:variable>
  1197.                 <xsl:variable name="previous-num-and-pos">
  1198.                     <xsl:call-template name="get-previous-number">
  1199.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1200.                         <xsl:with-param name="position" select="$num-pos"/>
  1201.                     </xsl:call-template>
  1202.                 </xsl:variable>
  1203.                 <xsl:if test="$skipcount > 0">
  1204.                     <xsl:call-template name="get-number-before">
  1205.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1206.                         <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
  1207.                         <xsl:with-param name="count" select="$count"/>
  1208.                         <xsl:with-param name="skipcount" select="$skipcount - 1"/>
  1209.                         <xsl:with-param name="number" select="$number"/>
  1210.                     </xsl:call-template>
  1211.                 </xsl:if>
  1212.                 <xsl:if test="$skipcount = 0">
  1213.                     <xsl:variable name="new-number">
  1214.                         <xsl:if test="not($count  = 1)">
  1215.                             <xsl:value-of select="' '"/>
  1216.                         </xsl:if>
  1217.                         <xsl:value-of select=" concat( substring-before($previous-num-and-pos , ':')  , $number ) "/>
  1218.                     </xsl:variable>
  1219.                     <xsl:call-template name="get-number-before">
  1220.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1221.                         <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
  1222.                         <xsl:with-param name="count" select="$count - 1"/>
  1223.                         <xsl:with-param name="skipcount" select="0"/>
  1224.                         <xsl:with-param name="number" select="$new-number"/>
  1225.                     </xsl:call-template>
  1226.                 </xsl:if>
  1227.             </xsl:otherwise>
  1228.         </xsl:choose>
  1229.     </xsl:template>
  1230.     <xsl:template name="get-number-after">
  1231.         <!--  get $count number of number after current position, output format:number1 number2 ... numberN:newpostion
  1232.             skip $skipcount of numbers
  1233.         -->
  1234.         <xsl:param name="vml-path"/>
  1235.         <xsl:param name="position" select="1"/>
  1236.         <xsl:param name="count" select="1"/>
  1237.         <xsl:param name="skipcount" select="0"/>
  1238.         <xsl:param name="number" select="''"/>
  1239.         <xsl:choose>
  1240.             <xsl:when test="$count = 0">
  1241.                 <xsl:value-of select=" concat($number ,   ':' , $position) "/>
  1242.             </xsl:when>
  1243.             <xsl:otherwise>
  1244.                 <xsl:variable name="num-pos">
  1245.                     <xsl:call-template name="get-number-position">
  1246.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1247.                         <xsl:with-param name="position" select="$position"/>
  1248.                         <xsl:with-param name="direction" select="1"/>
  1249.                     </xsl:call-template>
  1250.                 </xsl:variable>
  1251.                 <xsl:variable name="next-num-and-pos">
  1252.                     <xsl:call-template name="get-next-number">
  1253.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1254.                         <xsl:with-param name="position" select="$num-pos"/>
  1255.                     </xsl:call-template>
  1256.                 </xsl:variable>
  1257.                 <xsl:if test="$skipcount > 0">
  1258.                     <xsl:call-template name="get-number-after">
  1259.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1260.                         <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
  1261.                         <xsl:with-param name="count" select="$count"/>
  1262.                         <xsl:with-param name="skipcount" select="$skipcount - 1"/>
  1263.                         <xsl:with-param name="number" select="$number"/>
  1264.                     </xsl:call-template>
  1265.                 </xsl:if>
  1266.                 <xsl:if test="$skipcount = 0">
  1267.                     <xsl:variable name="new-number">
  1268.                         <xsl:value-of select=" concat( $number , substring-before($next-num-and-pos , ':') ) "/>
  1269.                         <xsl:if test="not($count  = 1)">
  1270.                             <xsl:value-of select="' '"/>
  1271.                         </xsl:if>
  1272.                     </xsl:variable>
  1273.                     <xsl:call-template name="get-number-after">
  1274.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1275.                         <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
  1276.                         <xsl:with-param name="count" select="$count - 1"/>
  1277.                         <xsl:with-param name="skipcount" select="0"/>
  1278.                         <xsl:with-param name="number" select="$new-number"/>
  1279.                     </xsl:call-template>
  1280.                 </xsl:if>
  1281.             </xsl:otherwise>
  1282.         </xsl:choose>
  1283.     </xsl:template>
  1284.     <xsl:template name="get-number-position">
  1285.         <!-- get the next number start position, direction should be 1  or -1-->
  1286.         <xsl:param name="vml-path"/>
  1287.         <xsl:param name="position"/>
  1288.         <xsl:param name="direction" select="1"/>
  1289.         <xsl:choose>
  1290.             <xsl:when test="$direction  = 1 and $position > string-length($vml-path) ">0</xsl:when>
  1291.             <xsl:when test="$direction  = -1 and not($position > 0)">0</xsl:when>
  1292.             <xsl:otherwise>
  1293.                 <xsl:variable name="curr-char">
  1294.                     <xsl:if test="$direction = 1">
  1295.                         <xsl:value-of select="substring($vml-path, $position , 1)"/>
  1296.                     </xsl:if>
  1297.                     <xsl:if test="$direction = -1">
  1298.                         <xsl:value-of select="substring($vml-path, $position -1 , 1)"/>
  1299.                     </xsl:if>
  1300.                 </xsl:variable>
  1301.                 <xsl:choose>
  1302.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789@' ,'')) = 0 ">
  1303.                         <!-- number start-->
  1304.                         <xsl:value-of select="$position"/>
  1305.                     </xsl:when>
  1306.                     <xsl:when test="not($curr-char = ' ')">
  1307.                         <xsl:value-of select="$position"/>
  1308.                     </xsl:when>
  1309.                     <xsl:otherwise>
  1310.                         <xsl:call-template name="get-number-position">
  1311.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1312.                             <xsl:with-param name="position" select="$position + $direction"/>
  1313.                             <xsl:with-param name="direction" select="$direction"/>
  1314.                         </xsl:call-template>
  1315.                     </xsl:otherwise>
  1316.                 </xsl:choose>
  1317.             </xsl:otherwise>
  1318.         </xsl:choose>
  1319.     </xsl:template>
  1320.     <xsl:template name="skip-space">
  1321.         <xsl:param name="vml-path"/>
  1322.         <xsl:param name="position"/>
  1323.         <xsl:param name="skip-comma" select="'yes'"/>
  1324.         <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1325.         <xsl:choose>
  1326.             <xsl:when test="$curr-char = ',' and $skip-comma = 'yes'">
  1327.                 <xsl:call-template name="skip-space">
  1328.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1329.                     <xsl:with-param name="position" select="$position+1"/>
  1330.                     <xsl:with-param name="skip-comma" select="'no'"/>
  1331.                 </xsl:call-template>
  1332.             </xsl:when>
  1333.             <xsl:when test="$curr-char = ' '">
  1334.                 <xsl:call-template name="skip-space">
  1335.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1336.                     <xsl:with-param name="position" select="$position+1"/>
  1337.                     <xsl:with-param name="skip-comma" select="$skip-comma"/>
  1338.                 </xsl:call-template>
  1339.             </xsl:when>
  1340.             <xsl:otherwise>
  1341.                 <xsl:value-of select="$position"/>
  1342.             </xsl:otherwise>
  1343.         </xsl:choose>
  1344.     </xsl:template>
  1345.     <xsl:template name="format-number-pos">
  1346.         <xsl:param name="number"/>
  1347.         <xsl:param name="position"/>
  1348.         <xsl:choose>
  1349.             <xsl:when test="contains($number,'@')">
  1350.                 <xsl:value-of select="concat('?f',translate($number,'@',''),':' , $position ) "/>
  1351.             </xsl:when>
  1352.             <xsl:otherwise>
  1353.                 <xsl:value-of select=" concat(round($number) ,  ':' , $position) "/>
  1354.             </xsl:otherwise>
  1355.         </xsl:choose>
  1356.     </xsl:template>
  1357.     <xsl:template name="get-next-number">
  1358.         <!-- get the next number from current position-->
  1359.         <xsl:param name="vml-path"/>
  1360.         <xsl:param name="position"/>
  1361.         <xsl:param name="number" select=" '' "/>
  1362.         <xsl:choose>
  1363.             <xsl:when test="$position > string-length($vml-path) ">
  1364.                 <xsl:call-template name="format-number-pos">
  1365.                     <xsl:with-param name="number" select="$number"/>
  1366.                     <xsl:with-param name="position" select="$position"/>
  1367.                 </xsl:call-template>
  1368.             </xsl:when>
  1369.             <xsl:otherwise>
  1370.                 <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1371.                 <xsl:choose>
  1372.                     <xsl:when test="string-length(translate($curr-char ,  '.0123456789' ,'')) = 0 ">
  1373.                         <!-- is number -->
  1374.                         <xsl:call-template name="get-next-number">
  1375.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1376.                             <xsl:with-param name="position" select="$position +1"/>
  1377.                             <xsl:with-param name="number" select="concat( $number, $curr-char) "/>
  1378.                         </xsl:call-template>
  1379.                     </xsl:when>
  1380.                     <xsl:when test="string-length(translate($curr-char ,  '@+-' ,'') ) = 0  and string-length($number) = 0">
  1381.                         <!-- is number -->
  1382.                         <xsl:call-template name="get-next-number">
  1383.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1384.                             <xsl:with-param name="position" select="$position +1"/>
  1385.                             <xsl:with-param name="number" select="concat( $number, $curr-char) "/>
  1386.                         </xsl:call-template>
  1387.                     </xsl:when>
  1388.                     <xsl:when test=" $number = '' and $curr-char = ',' ">
  1389.                         <xsl:variable name="new-pos">
  1390.                             <xsl:call-template name="skip-space">
  1391.                                 <xsl:with-param name="vml-path" select="$vml-path"/>
  1392.                                 <xsl:with-param name="position" select="$position"/>
  1393.                             </xsl:call-template>
  1394.                         </xsl:variable>
  1395.                         <xsl:value-of select="concat( '0:' , $new-pos )"/>
  1396.                     </xsl:when>
  1397.                     <xsl:when test=" $number = '' and not($curr-char = ',') ">
  1398.                         <xsl:variable name="new-pos">
  1399.                             <xsl:call-template name="skip-space">
  1400.                                 <xsl:with-param name="vml-path" select="$vml-path"/>
  1401.                                 <xsl:with-param name="position" select="$position"/>
  1402.                             </xsl:call-template>
  1403.                         </xsl:variable>
  1404.                         <xsl:value-of select="concat( '0:' , $new-pos)"/>
  1405.                     </xsl:when>
  1406.                     <xsl:otherwise>
  1407.                         <xsl:variable name="new-pos">
  1408.                             <xsl:call-template name="skip-space">
  1409.                                 <xsl:with-param name="vml-path" select="$vml-path"/>
  1410.                                 <xsl:with-param name="position" select="$position"/>
  1411.                             </xsl:call-template>
  1412.                         </xsl:variable>
  1413.                         <xsl:call-template name="format-number-pos">
  1414.                             <xsl:with-param name="number" select="$number"/>
  1415.                             <xsl:with-param name="position" select="$new-pos"/>
  1416.                         </xsl:call-template>
  1417.                     </xsl:otherwise>
  1418.                 </xsl:choose>
  1419.             </xsl:otherwise>
  1420.         </xsl:choose>
  1421.     </xsl:template>
  1422.     <xsl:template name="get-previous-number">
  1423.         <!-- get the previous number from current position-->
  1424.         <xsl:param name="vml-path"/>
  1425.         <xsl:param name="position"/>
  1426.         <xsl:param name="number" select="''"/>
  1427.         <xsl:choose>
  1428.             <xsl:when test="not($position > 0)">
  1429.                 <xsl:call-template name="format-number-pos">
  1430.                     <xsl:with-param name="number" select="$number"/>
  1431.                     <xsl:with-param name="position" select="'0'"/>
  1432.                 </xsl:call-template>
  1433.             </xsl:when>
  1434.             <xsl:otherwise>
  1435.                 <xsl:variable name="curr-char" select="substring($vml-path, $position -1 , 1)"/>
  1436.                 <xsl:choose>
  1437.                     <xsl:when test="string-length(translate($curr-char ,  '.0123456789' ,'')) = 0 ">
  1438.                         <!-- is number -->
  1439.                         <xsl:call-template name="get-previous-number">
  1440.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1441.                             <xsl:with-param name="position" select="$position -1"/>
  1442.                             <xsl:with-param name="number" select="concat($curr-char ,  $number) "/>
  1443.                         </xsl:call-template>
  1444.                     </xsl:when>
  1445.                     <xsl:when test="string-length(translate($curr-char ,  '@+-' ,'') ) = 0  and string-length($number) = 0">
  1446.                         <!-- skip it -->
  1447.                         <xsl:call-template name="get-previous-number">
  1448.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1449.                             <xsl:with-param name="position" select="$position -1"/>
  1450.                             <xsl:with-param name="number" select="$number "/>
  1451.                         </xsl:call-template>
  1452.                     </xsl:when>
  1453.                     <xsl:when test="string-length(translate($curr-char ,  '+-' ,'') ) = 0  and string-length($number) > 0">
  1454.                         <!-- finsh it with +/- -->
  1455.                         <xsl:call-template name="format-number-pos">
  1456.                             <xsl:with-param name="number" select="$number"/>
  1457.                             <xsl:with-param name="position" select="$position"/>
  1458.                         </xsl:call-template>
  1459.                     </xsl:when>
  1460.                     <xsl:otherwise>
  1461.                         <xsl:call-template name="format-number-pos">
  1462.                             <xsl:with-param name="number" select="$number"/>
  1463.                             <xsl:with-param name="position" select="$position"/>
  1464.                         </xsl:call-template>
  1465.                     </xsl:otherwise>
  1466.                 </xsl:choose>
  1467.             </xsl:otherwise>
  1468.         </xsl:choose>
  1469.     </xsl:template>
  1470.     <xsl:template name="get-path-command_dummy">
  1471.         <xsl:param name="vml-path"/>
  1472.         <xsl:param name="position" select="1"/>
  1473.         <xsl:param name="last-command"/>
  1474.         <xsl:choose>
  1475.             <xsl:when test="$position > string-length($vml-path) "/>
  1476.             <xsl:otherwise>
  1477.                 <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1478.                 <xsl:choose>
  1479.                     <xsl:when test="string-length(translate($curr-char ,  'mlcxetrvnfsawqyb' ,'')) = 0 ">
  1480.                         <!-- "MmZzLlHhVvCcSsQqTtAa" are all possiable  command chars -->
  1481.                         <xsl:value-of select="concat( $curr-char , ':'  , $position +1)"/>
  1482.                     </xsl:when>
  1483.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789@' ,'')) = 0 ">
  1484.                         <!-- number start, use last command -->
  1485.                         <xsl:if test="string-length($last-command) = 0">
  1486.                             <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
  1487.                         </xsl:if>
  1488.                         <xsl:value-of select="concat( $last-command  , ':'  , $position )"/>
  1489.                     </xsl:when>
  1490.                     <xsl:when test="string-length(translate($curr-char ,  ', ' ,'')) = 0 ">
  1491.                         <!-- space or ',' should be skip -->
  1492.                         <xsl:call-template name="get-path-command">
  1493.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1494.                             <xsl:with-param name="position" select="$position +1"/>
  1495.                             <xsl:with-param name="last-command" select="$last-command"/>
  1496.                         </xsl:call-template>
  1497.                     </xsl:when>
  1498.                     <xsl:otherwise>
  1499.                         <xsl:message>ooo2wordml_path.xsl: Find undefined command:<xsl:value-of select="$curr-char"/>
  1500.                         </xsl:message>
  1501.                     </xsl:otherwise>
  1502.                 </xsl:choose>
  1503.             </xsl:otherwise>
  1504.         </xsl:choose>
  1505.     </xsl:template>
  1506.     <!--
  1507.         **get-path- command**
  1508.         This function will collect the next command from a string. If the input string should has a start of number character,
  1509.         we here implictly think the command is the last-command
  1510.         All of the command of vml is listed as following:
  1511.         __Basic commands:__
  1512.         m        l        c        x        e        t        r        v        nf        ns        ae        al        at        ar        wa        wr        qx        qy        qb    
  1513.         __Edit behavior extensions commands__
  1514.         ha     hb    hc    hd    he    hf    hg    hh    hi
  1515.  
  1516.         So we know the longest command should be four character.The function is implemented on this basis:
  1517.      -->
  1518.     <xsl:template name="get-path-command">
  1519.         <xsl:param name="vml-path"/>
  1520.         <xsl:param name="position" select="1"/>
  1521.         <xsl:param name="last-command"/>
  1522.         <xsl:choose>
  1523.             <xsl:when test="$position > string-length($vml-path) "/>
  1524.             <xsl:otherwise>
  1525.                 <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1526.                 <xsl:variable name="curr-2char" select="substring($vml-path, $position - 1 , 2)"/>
  1527.                 <xsl:choose>
  1528.                     <xsl:when test="$curr-char = 'a' ">
  1529.                         <!--process the commands ae al at ar-->
  1530.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1531.                         <xsl:variable name="isvalid">
  1532.                             <xsl:choose>
  1533.                                 <xsl:when test="$second-char='e' ">1</xsl:when>
  1534.                                 <xsl:when test="$second-char='l' ">1</xsl:when>
  1535.                                 <xsl:when test="$second-char='t' ">1</xsl:when>
  1536.                                 <xsl:when test="$second-char='r' ">1</xsl:when>
  1537.                                 <xsl:otherwise>0</xsl:otherwise>
  1538.                             </xsl:choose>
  1539.                         </xsl:variable>
  1540.                         <xsl:if test="$isvalid = '1' ">
  1541.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1542.                         </xsl:if>
  1543.                         <xsl:if test="$isvalid = '0' ">
  1544.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1545.                         </xsl:if>
  1546.                     </xsl:when>
  1547.                     <xsl:when test="$curr-char = 'n' ">
  1548.                         <!--process the commands nf ns -->
  1549.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1550.                         <xsl:variable name="isvalid">
  1551.                             <xsl:choose>
  1552.                                 <xsl:when test="$second-char='f' ">1</xsl:when>
  1553.                                 <xsl:when test="$second-char='s' ">1</xsl:when>
  1554.                                 <xsl:otherwise>0</xsl:otherwise>
  1555.                             </xsl:choose>
  1556.                         </xsl:variable>
  1557.                         <xsl:if test="$isvalid = '1' ">
  1558.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1559.                         </xsl:if>
  1560.                         <xsl:if test="$isvalid = '0' ">
  1561.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1562.                         </xsl:if>
  1563.                     </xsl:when>
  1564.                     <xsl:when test="$curr-char = 'w' ">
  1565.                         <!--process the commands wa wr-->
  1566.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1567.                         <xsl:variable name="isvalid">
  1568.                             <xsl:choose>
  1569.                                 <xsl:when test="$second-char='a' ">1</xsl:when>
  1570.                                 <xsl:when test="$second-char='r' ">1</xsl:when>
  1571.                                 <xsl:otherwise>0</xsl:otherwise>
  1572.                             </xsl:choose>
  1573.                         </xsl:variable>
  1574.                         <xsl:if test="$isvalid = '1' ">
  1575.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1576.                         </xsl:if>
  1577.                         <xsl:if test="$isvalid = '0' ">
  1578.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1579.                         </xsl:if>
  1580.                     </xsl:when>
  1581.                     <xsl:when test="$curr-char = 'q' ">
  1582.                         <!--process the commands qx qy qb-->
  1583.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1584.                         <xsl:variable name="isvalid">
  1585.                             <xsl:choose>
  1586.                                 <xsl:when test="$second-char='x' ">1</xsl:when>
  1587.                                 <xsl:when test="$second-char='y' ">1</xsl:when>
  1588.                                 <xsl:when test="$second-char='b' ">1</xsl:when>
  1589.                                 <xsl:otherwise>0</xsl:otherwise>
  1590.                             </xsl:choose>
  1591.                         </xsl:variable>
  1592.                         <xsl:if test="$isvalid = '1' ">
  1593.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1594.                         </xsl:if>
  1595.                         <xsl:if test="$isvalid = '0' ">
  1596.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1597.                         </xsl:if>
  1598.                     </xsl:when>
  1599.                     <xsl:when test="$curr-char = 'h' ">
  1600.                         <!--process the edit behavior extensions commands-->
  1601.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1602.                         <xsl:variable name="isvalid">
  1603.                             <xsl:choose>
  1604.                                 <xsl:when test="string-length(translate($second-char ,  'abcdefghi' ,'')) = 0">1</xsl:when>
  1605.                                 <xsl:otherwise>0</xsl:otherwise>
  1606.                             </xsl:choose>
  1607.                         </xsl:variable>
  1608.                         <xsl:if test="$isvalid = '1' ">
  1609.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1610.                         </xsl:if>
  1611.                         <xsl:if test="$isvalid = '0' ">
  1612.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1613.                         </xsl:if>
  1614.                     </xsl:when>
  1615.                     <xsl:when test="string-length(translate($curr-char ,  'mlcxetrv' ,'')) = 0 ">
  1616.                         <!--process the single character commands m l c x e t r v -->
  1617.                         <xsl:value-of select="concat( $curr-char , ':'  , $position +1)"/>
  1618.                     </xsl:when>
  1619.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789@' ,'')) = 0 ">
  1620.                         <!-- number start, use last command -->
  1621.                         <xsl:if test="string-length($last-command) = 0">
  1622.                             <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
  1623.                         </xsl:if>
  1624.                         <xsl:value-of select="concat( $last-command  , ':'  , $position )"/>
  1625.                     </xsl:when>
  1626.                     <xsl:when test="$curr-2char=',,' ">
  1627.                         <!-- here are two ',' -->
  1628.                         <xsl:if test="string-length($last-command) = 0">
  1629.                             <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
  1630.                         </xsl:if>
  1631.                         <xsl:value-of select="concat( $last-command  , ':'  , $position  )"/>
  1632.                     </xsl:when>
  1633.                     <xsl:when test="string-length(translate($curr-char ,  ', ' ,'')) = 0 ">
  1634.                         <!-- space or ',' should be skip -->
  1635.                         <xsl:call-template name="get-path-command">
  1636.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1637.                             <xsl:with-param name="position" select="$position +1"/>
  1638.                             <xsl:with-param name="last-command" select="$last-command"/>
  1639.                         </xsl:call-template>
  1640.                     </xsl:when>
  1641.                     <xsl:otherwise>
  1642.                         <xsl:message>ooo2wordml_path.xsl: Find undefined command:<xsl:value-of select="$curr-char"/>
  1643.                         </xsl:message>
  1644.                     </xsl:otherwise>
  1645.                 </xsl:choose>
  1646.             </xsl:otherwise>
  1647.         </xsl:choose>
  1648.     </xsl:template>
  1649.     <xsl:template name="svg-arc2vml-arc">
  1650.         <xsl:param name="x0"/>
  1651.         <xsl:param name="y0"/>
  1652.         <xsl:param name="rx"/>
  1653.         <xsl:param name="ry"/>
  1654.         <xsl:param name="x-axis-rotation" select="0"/>
  1655.         <xsl:param name="large-arc-flag" select="0"/>
  1656.         <xsl:param name="sweep-flag" select="0"/>
  1657.         <xsl:param name="x"/>
  1658.         <xsl:param name="y"/>
  1659.         <!-- Compute 1/2 distance between current and final point -->
  1660.         <xsl:variable name="dx2" select="($x0 - $x) div 2"/>
  1661.         <xsl:variable name="dy2" select="($y0 - $y) div 2"/>
  1662.         <!--    Convert from degrees to radians -->
  1663.         <xsl:variable name="rotation-radian" select="$x-axis-rotation * $pi div 180"/>
  1664.         <!-- Compute (x1, y1). What are x1,y1?-->
  1665.         <xsl:variable name="cos-rotation">
  1666.             <xsl:call-template name="cos">
  1667.                 <xsl:with-param name="x" select="$rotation-radian"/>
  1668.             </xsl:call-template>
  1669.         </xsl:variable>
  1670.         <xsl:variable name="sin-rotation">
  1671.             <xsl:call-template name="sin">
  1672.                 <xsl:with-param name="x" select="$rotation-radian"/>
  1673.             </xsl:call-template>
  1674.         </xsl:variable>
  1675.         <xsl:variable name="x1" select="$cos-rotation * $dx2 + $sin-rotation * $dy2"/>
  1676.         <xsl:variable name="y1" select="-1 * $sin-rotation  * $dx2 + $cos-rotation * $dy2"/>
  1677.         <!-- Make sure radii are large enough -->
  1678.         <xsl:variable name="rx-abs">
  1679.             <xsl:call-template name="abs">
  1680.                 <xsl:with-param name="x" select="$rx"/>
  1681.             </xsl:call-template>
  1682.         </xsl:variable>
  1683.         <xsl:variable name="ry-abs">
  1684.             <xsl:call-template name="abs">
  1685.                 <xsl:with-param name="x" select="$ry"/>
  1686.             </xsl:call-template>
  1687.         </xsl:variable>
  1688.         <xsl:variable name="rx-sq" select="$rx-abs * $rx-abs"/>
  1689.         <xsl:variable name="ry-sq" select="$ry-abs * $ry-abs"/>
  1690.         <xsl:variable name="x1-sq" select="$x1 * $x1"/>
  1691.         <xsl:variable name="y1-sq" select="$y1 * $y1"/>
  1692.         <xsl:variable name="radius-check" select=" $x1-sq div $rx-sq + $y1-sq div $ry-sq "/>
  1693.         <xsl:variable name="radius-check-sqrt">
  1694.             <xsl:call-template name="sqrt">
  1695.                 <xsl:with-param name="x" select="$radius-check"/>
  1696.             </xsl:call-template>
  1697.         </xsl:variable>
  1698.         <xsl:variable name="new-rx">
  1699.             <xsl:choose>
  1700.                 <xsl:when test="$radius-check > 1">
  1701.                     <xsl:value-of select="$rx-abs * $radius-check-sqrt"/>
  1702.                 </xsl:when>
  1703.                 <xsl:otherwise>
  1704.                     <xsl:value-of select="$rx-abs"/>
  1705.                 </xsl:otherwise>
  1706.             </xsl:choose>
  1707.         </xsl:variable>
  1708.         <xsl:variable name="new-ry">
  1709.             <xsl:choose>
  1710.                 <xsl:when test="$radius-check > 1">
  1711.                     <xsl:value-of select="$ry-abs * $radius-check-sqrt"/>
  1712.                 </xsl:when>
  1713.                 <xsl:otherwise>
  1714.                     <xsl:value-of select="$ry-abs"/>
  1715.                 </xsl:otherwise>
  1716.             </xsl:choose>
  1717.         </xsl:variable>
  1718.         <xsl:variable name="new-ry-sq">
  1719.             <xsl:choose>
  1720.                 <xsl:when test="$radius-check > 1">
  1721.                     <xsl:value-of select="$new-ry * $new-ry"/>
  1722.                 </xsl:when>
  1723.                 <xsl:otherwise>
  1724.                     <xsl:value-of select="$ry-sq"/>
  1725.                 </xsl:otherwise>
  1726.             </xsl:choose>
  1727.         </xsl:variable>
  1728.         <xsl:variable name="new-rx-sq">
  1729.             <xsl:choose>
  1730.                 <xsl:when test="$radius-check > 1">
  1731.                     <xsl:value-of select="$new-rx * $new-rx"/>
  1732.                 </xsl:when>
  1733.                 <xsl:otherwise>
  1734.                     <xsl:value-of select="$rx-sq"/>
  1735.                 </xsl:otherwise>
  1736.             </xsl:choose>
  1737.         </xsl:variable>
  1738.         <!-- Step 2: Compute (cx1, cy1) -->
  1739.         <xsl:variable name="sign">
  1740.             <xsl:choose>
  1741.                 <xsl:when test="$large-arc-flag = $sweep-flag">-1</xsl:when>
  1742.                 <xsl:otherwise>1</xsl:otherwise>
  1743.             </xsl:choose>
  1744.         </xsl:variable>
  1745.         <xsl:variable name="unchecked-sq" select=" (($new-rx-sq * $new-ry-sq) - ($new-rx-sq * $y1-sq) - ($new-ry-sq * $x1-sq)) div   (($new-rx-sq * $y1-sq) + ($new-ry-sq * $x1-sq)) "/>
  1746.         <xsl:variable name="sq">
  1747.             <xsl:choose>
  1748.                 <xsl:when test=" $unchecked-sq < 0">0</xsl:when>
  1749.                 <xsl:otherwise>
  1750.                     <xsl:value-of select="$unchecked-sq"/>
  1751.                 </xsl:otherwise>
  1752.             </xsl:choose>
  1753.         </xsl:variable>
  1754.         <xsl:variable name="sq-sqrt">
  1755.             <xsl:call-template name="sqrt">
  1756.                 <xsl:with-param name="x" select="$sq"/>
  1757.             </xsl:call-template>
  1758.         </xsl:variable>
  1759.         <xsl:variable name="coef" select="$sign * $sq-sqrt "/>
  1760.         <xsl:variable name="cx1" select="$coef * $new-rx * $y1 div $new-ry"/>
  1761.         <xsl:variable name="cy1" select=" -1 * $coef * $new-ry * $x1 div $new-rx"/>
  1762.         <!--  Step 3: Compute (cx, cy) from (cx1, cy1) -->
  1763.         <xsl:variable name="sx2" select="($x0 +$x) div 2 "/>
  1764.         <xsl:variable name="sy2" select="($y0 +$y) div 2 "/>
  1765.         <xsl:variable name="tmp1" select="$cos-rotation * $cx1 "/>
  1766.         <xsl:variable name="tmp2" select="$cos-rotation * $cx1 "/>
  1767.         <xsl:variable name="cx" select=" $sx2 + ( $cos-rotation * $cx1 - $sin-rotation * $cy1 ) "/>
  1768.         <xsl:variable name="cy" select=" $sy2 + ( $sin-rotation * $cx1 + $cos-rotation * $cy1 ) "/>
  1769.         <!-- Step 4: Compute angle start and angle extent -->
  1770.         <xsl:variable name="ux" select="( $x1 - $cx1)  div $new-rx"/>
  1771.         <xsl:variable name="uy" select="( $y1 - $cy1)  div $new-ry"/>
  1772.         <xsl:variable name="vx" select="( - 1 *  $x1 - $cx1)  div $new-rx"/>
  1773.         <xsl:variable name="vy" select="(- 1 *  $y1 - $cy1)  div $new-ry"/>
  1774.         <xsl:variable name="n">
  1775.             <xsl:call-template name="sqrt">
  1776.                 <xsl:with-param name="x" select="  ($ux * $ux) + ($uy * $uy)  "/>
  1777.             </xsl:call-template>
  1778.         </xsl:variable>
  1779.         <!--  1 * ux + 0 * uy -->
  1780.         <xsl:variable name="p" select="$ux"/>
  1781.         <xsl:variable name="uy-sign">
  1782.             <xsl:choose>
  1783.                 <xsl:when test=" $uy < 0 ">-1</xsl:when>
  1784.                 <xsl:otherwise>1</xsl:otherwise>
  1785.             </xsl:choose>
  1786.         </xsl:variable>
  1787.         <xsl:variable name="acos-pn">
  1788.             <xsl:call-template name="acos">
  1789.                 <xsl:with-param name="x" select="$p div $n"/>
  1790.             </xsl:call-template>
  1791.         </xsl:variable>
  1792.         <xsl:variable name="theta" select="( $uy-sign * $acos-pn * 180 div $pi ) mod 360 "/>
  1793.         <xsl:variable name="n-delta">
  1794.             <xsl:call-template name="sqrt">
  1795.                 <xsl:with-param name="x" select="($ux * $ux + $uy * $uy) * ($vx * $vx + $vy * $vy)"/>
  1796.             </xsl:call-template>
  1797.         </xsl:variable>
  1798.         <xsl:variable name="p-delta" select="$ux * $vx + $uy * $vy"/>
  1799.         <xsl:variable name="vy-sign">
  1800.             <xsl:choose>
  1801.                 <xsl:when test="($ux * $vy - $uy * $vx)   < 0 ">-1</xsl:when>
  1802.                 <xsl:otherwise>1</xsl:otherwise>
  1803.             </xsl:choose>
  1804.         </xsl:variable>
  1805.         <xsl:variable name="acos-pn-delta">
  1806.             <xsl:call-template name="acos">
  1807.                 <xsl:with-param name="x" select="$p-delta div $n-delta"/>
  1808.             </xsl:call-template>
  1809.         </xsl:variable>
  1810.         <xsl:variable name="unchecked-delta" select="$vy-sign * $acos-pn-delta * 180 div $pi "/>
  1811.         <xsl:variable name="delta">
  1812.             <xsl:choose>
  1813.                 <xsl:when test=" $sweep-flag = 0 and $unchecked-delta > 0 ">
  1814.                     <xsl:value-of select=" ($unchecked-delta - 360) mod 360 "/>
  1815.                 </xsl:when>
  1816.                 <xsl:when test=" $sweep-flag = 1 and $unchecked-delta < 0 ">
  1817.                     <xsl:value-of select=" ($unchecked-delta + 360) mod 360 "/>
  1818.                 </xsl:when>
  1819.                 <xsl:otherwise>
  1820.                     <xsl:value-of select=" $unchecked-delta  mod 360 "/>
  1821.                 </xsl:otherwise>
  1822.             </xsl:choose>
  1823.         </xsl:variable>
  1824.         <xsl:value-of select="concat ($cx,  ' ' , $cy, ' ' ,  $rx, ' ' ,  $ry, ' ' ,  $theta, ' ' , $delta,  ' ' , $x-axis-rotation) "/>
  1825.     </xsl:template>
  1826. </xsl:stylesheet>
  1827.